package keeto.com.vn.bms.ui.widget;

import keeto.com.vn.bms.config.BMSCore;
import keeto.com.vn.bms.config.IBMSConfig;
import keeto.com.vn.bms.ui.activity.R;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;

public class DeleteDialog extends Dialog implements android.view.View.OnClickListener {
	private Context ctx;
	private Button btnOk;
	private Button btnCancel;

	private LinearLayout llParent;


	public DeleteDialog(Context context) {
		super(context);
		this.ctx=context;
	}


	public DeleteDialog(Context context, int theme) {
		super(context, theme);
		// TODO Auto-generated constructor stub
	}


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.layout_dialog_delete);
		llParent = (LinearLayout)findViewById(R.id.parent_delete_dialog);
		btnOk = (Button)findViewById(R.id.btn_yes_delete);
		btnCancel = (Button)findViewById(R.id.btn_cancel_delete);
		btnOk.setOnClickListener(this);
		btnCancel.setOnClickListener(this);
		this.setCanceledOnTouchOutside(false);
		Rect displayRectangle = new Rect();
        Window window = this.getWindow();
        window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle);
        llParent.setMinimumWidth((int) (displayRectangle.width()* 0.9f));
	}


	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.btn_yes_delete:
			boolean bool=true;
			Intent intent = new Intent();
			Bundle bundle = new Bundle();
			bundle.putBoolean("BOOLEAN", bool);
			intent.putExtra("BUNDLE", bundle);
			intent.setAction(IBMSConfig.KEY_ACTION_DELETE_FILE);
			ctx.sendBroadcast(intent);
			break;
		case R.id.btn_cancel_delete:
			this.dismiss();
			break;

		default:
			break;
		}
	}
	
}
